/**
 * Created by PanJiaChen on 16/11/18.
 */

/**
 * @param {string} path
 * @returns {Boolean}
 */
export function isExternal (path) {
  return /^(https?:|mailto:|tel:)/.test(path)
}

/**
 * @param {string} str
 * @returns {Boolean}
 */
export function validUsername (str) {
  const valid_map = ['admin', 'editor']
  return valid_map.indexOf(str.trim()) >= 0
}

export function dianhuahaoma (rule, value, callback) {
  const reg = /^(0|86|17951)?(13[0-9]|15[012356789]|166|17[3678]|18[0-9]|14[57])[0-9]{8}$/
  const boll = reg.test(value)
  if (boll) {
    callback()
  } else {
    callback(new Error('手机号不合法'))
  }
}
export function mimachangdu (rule, value, callback) {
  if (value.length >= 6) {
    callback()
  } else {
    callback(new Error('长度要大于等于6位'))
  }
}
